import {Component} from "react";

export default class Switch extends Component {
    constructor(props) {
        super(props);
        this.state = {
            isOpen: true,
        }
    }
    toggle = () => {
        this.setState(state => ({
            isOpen: !state.isOpen,
        }))
    }
    render() {
        return (
            <button
                className={this.state.isOpen ? 'switchOn' : 'switchOFF'}
                onClick={this.toggle}>{this.state.isOpen ? 'ON' : 'OFF'}</button>
        )
    }
}